package me.hetong.caigou.ui.stage;

import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import me.hetong.caigou.util.FxUtils;

public class Confirm {
    public static void confirm(String text, EventHandler<MouseEvent> event) {

        VBox vBox = new VBox();

        Stage stage = new Stage();
        stage.setScene(new Scene(vBox));
        stage.initModality(Modality.APPLICATION_MODAL);
        stage.setResizable(false);
        stage.setTitle("操作");

        {
            HBox hBox1 = new HBox();
            hBox1.setPrefWidth(300);
            Label label = new Label(text);
            label.setPadding(new Insets(10));
            hBox1.getChildren().add(label);
            vBox.getChildren().add(hBox1);
        }

        {
            HBox hBox = new HBox();
            hBox.setAlignment(Pos.CENTER_RIGHT);
            hBox.setSpacing(5);
            hBox.setStyle("-fx-padding: 10");
            hBox.getChildren().add(FxUtils.createLabelPro("取消", new EventHandler<MouseEvent>() {
                @Override
                public void handle(MouseEvent event) {
                    stage.close();
                }
            }));
            hBox.getChildren().add(FxUtils.createLabelPro("确定", event));
            vBox.getChildren().add(hBox);
        }

        stage.show();
//        new FadeIn(vBox).play();
    }
}
